#:  -*- coding: utf-8 -*-
import datetime
import time
import traceback

import pandas as pd
from gm.api import *
from tqdm.auto import tqdm

from chanlun import config
from chanlun.exchange.exchange_db import ExchangeDB

"""
同步股票数据到数据库中

使用的是 掘金量化 API 获取
"""

# 可以直接提取数据，掘金终端需要打开，接口取数是通过网络请求的方式，效率一般，行情数据可通过subscribe订阅方式

# 如在远程执行，需要制定掘金终端地址  https://www.myquant.cn/docs/gm3_faq/154#b244aeed0032526e
set_serv_addr(config.GM_SERVER_ADDR)
# 设置token， 查看已有token ID,在用户-秘钥管理里获取
set_token(config.GM_TOKEN)

db_ex = ExchangeDB('a')

# 获取沪深 股票/基金/指数 代码
# fund_stocks = get_instruments(symbols=None, exchanges=['SHSE', 'SZSE'],
#                               sec_types=[SEC_TYPE_FUND])
#
# stock_stocks = get_instruments(symbols=None, exchanges=['SHSE', 'SZSE'],
#                                sec_types=[SEC_TYPE_STOCK])
# run_codes = ['SHSE.000001'] + [s['symbol'] for s in stock_stocks] + [s['symbol'] for s in fund_stocks if
#                                                                      s['symbol'][0:7] in ['SHSE.51', 'SZSE.15']]

# 指定要更新的股票列表
run_codes = [
    'SHSE.000001', 'SHSE.000688', 'SZSE.399001', 'SZSE.399006',
    "SHSE.600519", "SHSE.601398", "SHSE.600941", "SHSE.601939", "SHSE.601288", "SZSE.300750", "SHSE.601988",
    "SHSE.601857", "SHSE.601628", "SZSE.002594", "SHSE.600036", "SHSE.601318", "SHSE.601088", "SZSE.000858",
    "SHSE.600028", "SHSE.600900", "SZSE.300760", "SHSE.601012", "SHSE.601728", "SHSE.601658", "SHSE.601888",
    "SHSE.601328", "SHSE.688981", "SHSE.601166", "SHSE.600809", "SZSE.000333", "SHSE.603288", "SZSE.002415",
    "SHSE.601633", "SHSE.600276", "SHSE.600030", "SHSE.600309", "SZSE.002714", "SZSE.002352", "SZSE.000568",
    "SHSE.603259", "SHSE.601816", "SHSE.601319", "SHSE.601998", "SHSE.601899", "SZSE.300999", "SZSE.300059",
    "SZSE.002475", "SHSE.600188", "SZSE.000001", "SHSE.601668", "SZSE.002304", "SHSE.600690", "SHSE.600438",
    "SHSE.600000", "SZSE.300274", "SHSE.601225", "SHSE.601066", "SHSE.601601", "SHSE.601919", "SZSE.300015",
    "SZSE.300124", "SHSE.688235", "SHSE.601995", "SHSE.600048", "SHSE.600406", "SHSE.688223", "SHSE.601138",
    "SHSE.600887", "SZSE.000651", "SHSE.600104", "SHSE.600905", "SZSE.002460", "SZSE.300014", "SZSE.000002",
    "SZSE.002142", "SZSE.002466", "SZSE.001289", "SZSE.002459", "SHSE.601818", "SHSE.600016", "SHSE.688599",
    "SHSE.600760", "SHSE.601111", "SZSE.002371", "SZSE.002049", "SHSE.600436", "SZSE.300122", "SHSE.601766",
    "SHSE.688111", "SZSE.003816", "SHSE.600009", "SZSE.002812", "SHSE.600893", "SHSE.600585", "SZSE.002129",
    "SZSE.000725", "SHSE.601390", "SHSE.600018", "SHSE.600150", "SHSE.601238", "SHSE.601211", "SZSE.300498",
    "SHSE.601898", "SZSE.000792", "SHSE.600025", "SHSE.600031", "SHSE.603392", "SHSE.601985", "SZSE.000625",
    "SHSE.600029", "SHSE.600600", "SHSE.600837", "SHSE.600999", "SHSE.601688", "SHSE.688303", "SZSE.002493",
    "SHSE.601800", "SHSE.600346", "SHSE.600019", "SHSE.601009", "SHSE.601669", "SHSE.600011", "SZSE.000063",
    "SZSE.002179", "SZSE.000596", "SHSE.600050", "SZSE.000776", "SHSE.603260", "SHSE.600919", "SZSE.001979",
    "SZSE.000538", "SZSE.000166", "SZSE.002311", "SHSE.601868", "SHSE.601006", "SHSE.601186", "SZSE.300316",
    "SHSE.601881", "SZSE.300896", "SHSE.600115", "SHSE.603993", "SHSE.688187", "SHSE.600196", "SHSE.600111",
    "SHSE.600660", "SHSE.603799", "SHSE.603501", "SHSE.601169", "SHSE.603806", "SHSE.600989", "SHSE.600588",
    "SHSE.600845", "SZSE.002736", "SZSE.300751", "SZSE.002709", "SZSE.002230", "SZSE.000708", "SZSE.002180",
    "SHSE.600026", "SHSE.600010", "SHSE.601808", "SHSE.601989", "SHSE.601229", "SZSE.000338", "SHSE.600570",
    "SHSE.600089", "SZSE.000895", "SZSE.300450", "SHSE.605117", "SHSE.600795", "SHSE.600547", "SHSE.600703",
    "SHSE.688385", "SZSE.002050", "SHSE.600015", "SZSE.000301", "SZSE.000768", "SHSE.600886", "SHSE.600522",
    "SZSE.002241", "SHSE.601865", "SHSE.601336", "SZSE.300347", "SHSE.600875", "SHSE.601100", "SHSE.603195",
    "SHSE.600926", "SZSE.000963", "SHSE.601689", "SZSE.300763", "SZSE.000733", "SHSE.603659", "SHSE.601127",
    "SZSE.002938", "SHSE.688012", "SHSE.601018", "SHSE.600256", "SHSE.688396", "SHSE.600085", "SZSE.000877",
    "SHSE.601600", "SHSE.600958", "SZSE.000661", "SHSE.601607", "SHSE.600233", "SHSE.688180", "SZSE.002027",
    "SHSE.601788", "SHSE.688008", "SHSE.603290", "SZSE.300628", "SHSE.605499", "SZSE.300759", "SHSE.603613",
    "SZSE.002271", "SZSE.300142", "SZSE.300957", "SHSE.601727", "SHSE.601618", "SHSE.600745", "SZSE.002410",
    "SHSE.601916", "SZSE.000876", "SHSE.600754", "SZSE.002920", "SZSE.000617", "SHSE.601872", "SHSE.601615",
    "SHSE.600426", "SHSE.688126", "SZSE.002001", "SHSE.603986", "SZSE.000100", "SZSE.000425", "SHSE.601877",
    "SZSE.300408", "SHSE.600039", "SHSE.688122", "SZSE.000999", "SHSE.600027", "SZSE.002074", "SZSE.300661",
    "SHSE.600362", "SZSE.002821", "SHSE.688234", "SHSE.603606", "SHSE.600741", "SHSE.600765", "SZSE.300454",
    "SHSE.601991", "SHSE.601901", "SHSE.601825", "SHSE.688363", "SZSE.002603", "SHSE.601360", "SHSE.601699",
    "SHSE.601838", "SHSE.688036", "SHSE.603833", "SZSE.300433", "SHSE.601698", "SZSE.300782", "SHSE.600236",
    "SHSE.600674", "SZSE.000938", "SHSE.688032", "SHSE.603185", "SZSE.002756", "SHSE.600221", "SHSE.688777",
    "SHSE.688009", "SHSE.600803", "SHSE.600536", "SZSE.300003", "SHSE.688063", "SHSE.603605", "SZSE.300979",
    "SZSE.300724", "SHSE.601377", "SHSE.603688", "SHSE.688185", "SHSE.603369", "SHSE.600176", "SZSE.001965",
    "SZSE.000983", "SZSE.000157", "SHSE.600487", "SZSE.300033", "SZSE.002013", "SZSE.300832", "SZSE.002841",
    "SZSE.300496", "SZSE.300769", "SHSE.600023", "SHSE.601021", "SHSE.600460", "SHSE.600918", "SZSE.002202",
    "SHSE.600515", "SZSE.300919", "SHSE.600332", "SZSE.003022", "SHSE.603658", "SZSE.002384", "SHSE.601117",
    "SZSE.000408", "SHSE.600584", "SHSE.688561", "SHSE.600160", "SHSE.600132", "SHSE.688728", "SZSE.002648",
    "SHSE.600956", "SZSE.002430", "SHSE.688390", "SZSE.002738", "SZSE.300413", "SHSE.600348", "SHSE.603939",
    "SHSE.600884", "SZSE.300699", "SHSE.600732", "SZSE.300207", "SHSE.688819", "SHSE.600563", "SZSE.000975",
    "SHSE.601077", "SHSE.600862", "SZSE.000738", "SHSE.601878", "SHSE.603345", "SHSE.600763", "SHSE.600378",
    "SZSE.000629", "SHSE.600702", "SZSE.002916", "SHSE.601231", "SZSE.002120", "SZSE.002340", "SZSE.002414",
    "SHSE.601880", "SZSE.002385", "SHSE.688082", "SZSE.300442", "SZSE.000723", "SHSE.600685", "SHSE.603198",
    "SHSE.600377", "SHSE.600995", "SHSE.688301", "SZSE.002240", "SHSE.688065", "SHSE.603899", "SZSE.002625",
    "SHSE.600096", "SZSE.002945", "SHSE.688538", "SHSE.600061", "SHSE.600606", "SHSE.600219", "SHSE.600663",
    "SZSE.002601", "SZSE.002252", "SHSE.603019", "SZSE.002025", "SZSE.300390", "SZSE.300604", "SZSE.301029",
    "SHSE.600489", "SHSE.600153", "SZSE.000066", "SZSE.000039", "SHSE.600399", "SHSE.600885", "SHSE.600372",
    "SHSE.603596", "SHSE.688005", "SHSE.600383", "SHSE.603882", "SZSE.002422", "SZSE.002236", "SHSE.601799",
    "SHSE.600871", "SZSE.300601", "SHSE.600482", "SZSE.001872", "SHSE.600157", "SHSE.603233", "SZSE.002294",
    "SHSE.603868", "SHSE.601298", "SZSE.000069", "SHSE.603529", "SZSE.300395", "SHSE.600161", "SHSE.688516",
    "SZSE.000977", "SHSE.601236", "SZSE.000786", "SHSE.603486", "SZSE.002600", "SHSE.600688", "SHSE.601108",
    "SZSE.000799", "SHSE.601866", "SZSE.002064", "SZSE.000513", "SHSE.600004", "SHSE.601869", "SHSE.688248",
    "SHSE.601555", "SHSE.601216", "SZSE.300223", "SHSE.603737", "SHSE.600079", "SZSE.002223", "SZSE.002939",
    "SZSE.002176", "SZSE.000800", "SZSE.002032", "SZSE.002007", "SHSE.600985", "SHSE.600183", "SZSE.002555",
    "SHSE.603568", "SZSE.002568", "SZSE.000807", "SZSE.000933", "SZSE.300012", "SHSE.600298", "SHSE.600141",
    "SHSE.600988", "SHSE.600546", "SZSE.002353", "SZSE.002497", "SHSE.688536", "SZSE.002268", "SZSE.300474",
    "SHSE.603127", "SHSE.603712", "SHSE.600499", "SZSE.002831", "SHSE.603885", "SZSE.300144", "SHSE.688188",
    "SZSE.002080", "SZSE.300073", "SHSE.601155", "SZSE.000009", "SZSE.300146", "SHSE.600521", "SHSE.603456",
    "SHSE.600109", "SHSE.600352", "SHSE.600566", "SHSE.601696", "SHSE.601990", "SHSE.601233", "SHSE.688779",
    "SZSE.002518", "SZSE.002532", "SZSE.300438", "SHSE.605358", "SHSE.600848", "SHSE.600968", "SHSE.603517",
    "SZSE.002056", "SZSE.000783", "SHSE.600486", "SZSE.000519", "SZSE.002192", "SHSE.600549", "SZSE.000831",
    "SZSE.002185", "SZSE.002405", "SZSE.002078", "SZSE.300888", "SHSE.600801", "SHSE.600418", "SHSE.688220",
    "SHSE.600673", "SZSE.002409", "SZSE.000987", "SHSE.600295", "SZSE.000155", "SZSE.002372", "SZSE.002244",
    "SHSE.600177", "SZSE.000932", "SHSE.600779", "SHSE.600873", "SZSE.300776", "SHSE.600517", "SZSE.002602",
    "SZSE.000883", "SHSE.688276", "SZSE.300682", "SZSE.002299", "SHSE.603893", "SZSE.000728", "SHSE.600481",
    "SHSE.688107", "SHSE.603826", "SZSE.000027", "SHSE.601958", "SHSE.601933", "SZSE.002865", "SZSE.300037",
    "SZSE.002607", "SHSE.600705", "SZSE.000959", "SHSE.603267", "SZSE.002673", "SHSE.600118", "SZSE.002008",
    "SZSE.002487", "SHSE.601058", "SZSE.300595", "SHSE.688567", "SHSE.600350", "SZSE.002153", "SZSE.000630",
    "SHSE.601456", "SZSE.000591", "SHSE.600416", "SHSE.688256", "SZSE.300373", "SHSE.603707", "SHSE.601598",
    "SHSE.688778", "SZSE.300034", "SHSE.601577", "SHSE.600733", "SHSE.600038", "SZSE.300748", "SHSE.600642",
    "SHSE.600021", "SZSE.002028", "SHSE.600143", "SHSE.688521", "SZSE.300487", "SZSE.300529", "SHSE.603077",
    "SHSE.601666", "SZSE.002791", "SHSE.600518", "SZSE.002966", "SHSE.601198", "SZSE.002030", "SZSE.002156",
    "SZSE.301035", "SHSE.601992", "SHSE.600927", "SHSE.603816", "SHSE.688105", "SZSE.300357", "SHSE.600369",
    "SZSE.000703", "SZSE.000423", "SZSE.000537", "SZSE.000739", "SHSE.600598", "SHSE.688139", "SZSE.300633",
    "SHSE.600655", "SHSE.601158", "SHSE.600497", "SZSE.300260", "SHSE.600258", "SHSE.603589", "SHSE.601156",
    "SZSE.300777", "SZSE.002439", "SHSE.601966", "SHSE.603786", "SZSE.000032", "SZSE.002653", "SZSE.002389",
    "SHSE.688200", "SHSE.603876", "SZSE.000729", "SHSE.601162", "SZSE.002407", "SZSE.002432", "SZSE.300861",
    "SZSE.002128", "SHSE.688520", "SHSE.688099", "SZSE.300568", "SHSE.600998", "SZSE.002541", "SZSE.000893",
    "SHSE.600032", "SZSE.300308", "SHSE.600392", "SHSE.600906", "SZSE.002152", "SZSE.300775", "SHSE.600863",
    "SZSE.000683", "SZSE.002797", "SHSE.688598", "SHSE.603156", "SZSE.300363", "SHSE.688037", "SZSE.300285",
    "SZSE.000898", "SHSE.688690", "SZSE.000785", "SHSE.688161", "SZSE.000709", "SZSE.300850", "SHSE.603305",
    "SZSE.301155", "SHSE.600415", "SZSE.300676", "SZSE.000539", "SHSE.600859", "SHSE.601963", "SHSE.600170",
    "SHSE.600516", "SZSE.000980", "SHSE.688617", "SHSE.689009", "SHSE.601228", "SZSE.002203", "SZSE.000825",
    "SHSE.603338", "SHSE.601975", "SHSE.600299", "SHSE.688707", "SHSE.601168", "SZSE.300666", "SHSE.600380",
    "SHSE.688772", "SHSE.601001", "SHSE.601369", "SZSE.002557", "SHSE.601568", "SHSE.600057", "SHSE.603160",
    "SHSE.601179", "SZSE.002472", "SHSE.688116", "SZSE.000958", "SZSE.002624", "SHSE.601717", "SZSE.002444",
    "SZSE.002739", "SZSE.300118", "SZSE.002015", "SHSE.688169", "SZSE.003031", "SZSE.300866", "SHSE.601399",
    "SZSE.003035", "SZSE.000830", "SZSE.002608", "SZSE.300910", "SHSE.688700", "SZSE.000050", "SHSE.600704",
    "SZSE.300593", "SHSE.600208", "SZSE.000937", "SZSE.002850", "SHSE.601016", "SHSE.603317", "SHSE.603650",
    "SHSE.600329", "SHSE.603218", "SZSE.001227", "SZSE.002761", "SHSE.600872", "SZSE.300026", "SZSE.300298",
    "SHSE.603858", "SHSE.688002", "SZSE.002484", "SZSE.002531", "SZSE.002312", "SZSE.000012", "SHSE.688050",
    "SHSE.601636", "SHSE.600699", "SZSE.002266", "SZSE.002690", "SHSE.600578", "SHSE.600483", "SZSE.002399",
    "SHSE.600271", "SHSE.688425", "SZSE.300253", "SHSE.600583", "SHSE.600909", "SZSE.002463", "SHSE.688232",
    "SHSE.600637", "SHSE.603883", "SZSE.000516", "SZSE.002683", "SZSE.002262", "SHSE.600166", "SHSE.600582",
    "SHSE.688006", "SHSE.600008", "SZSE.002595", "SHSE.603678", "SZSE.000401", "SZSE.000762", "SHSE.600612",
    "SHSE.603129", "SHSE.600456", "SHSE.600390", "SZSE.002507", "SHSE.603087", "SZSE.300054", "SZSE.002436",
    "SHSE.600977", "SHSE.603505", "SZSE.000818", "SZSE.002145", "SZSE.000553", "SHSE.605123", "SZSE.002617",
    "SZSE.002065", "SHSE.600511", "SHSE.601611", "SZSE.300251", "SZSE.002335", "SHSE.688556", "SHSE.603026",
    "SHSE.600808", "SHSE.601106", "SHSE.600816", "SHSE.688083", "SHSE.688017", "SZSE.002465", "SZSE.002508",
    "SHSE.603236", "SHSE.600559", "SHSE.601567", "SHSE.600970", "SZSE.000887", "SHSE.600098", "SHSE.603599",
    "SZSE.002408", "SZSE.002926", "SHSE.688202", "SHSE.601777", "SHSE.600338", "SHSE.688261", "SHSE.601128",
    "SZSE.002506", "SZSE.002326", "SHSE.600246", "SZSE.000998", "SHSE.600500", "SHSE.601997", "SZSE.300558",
    "SZSE.000960", "SZSE.001213", "SHSE.601965", "SHSE.603565", "SHSE.600056", "SHSE.603713", "SZSE.002936",
    "SHSE.600315", "SHSE.600739", "SHSE.600282", "SHSE.601139", "SHSE.603355", "SHSE.600062", "SZSE.000878",
    "SHSE.601028", "SHSE.601212", "SHSE.688776", "SZSE.000869", "SHSE.688333", "SHSE.601665", "SHSE.688029",
    "SHSE.600398", "SZSE.002500", "SHSE.601928", "SHSE.600316", "SZSE.002597", "SHSE.688198", "SHSE.601828",
    "SHSE.603927", "SHSE.600879", "SZSE.002041", "SHSE.603444", "SHSE.600095", "SZSE.300726", "SHSE.600129",
    "SHSE.600325", "SZSE.300803", "SHSE.600562", "SHSE.600131", "SHSE.600827", "SZSE.300171", "SHSE.600641",
    "SZSE.000688", "SZSE.000400", "SHSE.603179", "SZSE.002948", "SHSE.688208", "SHSE.600548", "SHSE.603279",
    "SZSE.000021", "SZSE.001203", "SZSE.300346", "SZSE.000034", "SHSE.600916", "SHSE.603056", "SZSE.000750",
    "SHSE.600867", "SZSE.301071", "SZSE.300725", "SHSE.603348", "SZSE.300203", "SZSE.000564", "SHSE.600895",
    "SHSE.688568", "SHSE.600711", "SHSE.601908", "SZSE.300244", "SZSE.002317", "SHSE.601952", "SZSE.000581",
    "SHSE.601118", "SHSE.605111", "SZSE.002985", "SZSE.002250", "SZSE.002138", "SHSE.601099", "SZSE.002245",
    "SZSE.000981", "SHSE.603228", "SZSE.300428", "SZSE.300432", "SZSE.002468", "SZSE.000810", "SZSE.002747",
    "SHSE.603733", "SHSE.600596", "SHSE.601098", "SZSE.300070", "SHSE.600877", "SZSE.300627", "SZSE.002324",
    "SZSE.002901", "SZSE.002906", "SHSE.600110", "SZSE.000988", "SHSE.600320", "SZSE.002984", "SZSE.000547",
    "SZSE.002273", "SZSE.300761", "SHSE.600935", "SHSE.688019", "SHSE.601375", "SZSE.002044", "SHSE.600297",
    "SHSE.600933", "SZSE.300393", "SHSE.688066", "SHSE.600535", "SZSE.300101", "SZSE.301177", "SZSE.300257",
    "SZSE.002505", "SZSE.002727", "SZSE.002318", "SZSE.000875", "SHSE.600528", "SHSE.688499", "SZSE.002498",
    "SZSE.301039", "SZSE.000559", "SHSE.600529", "SHSE.600580", "SHSE.600498", "SZSE.300855", "SHSE.600820",
    "SZSE.301207", "SZSE.002773", "SZSE.300136", "SZSE.300009", "SZSE.300820", "SHSE.688686", "SHSE.688023",
    "SZSE.300747", "SZSE.300376", "SHSE.688676", "SHSE.688278", "SHSE.600777", "SZSE.000623", "SHSE.600277",
    "SHSE.688016", "SZSE.300083", "SHSE.688206", "SZSE.002024", "SZSE.002155", "SZSE.300068", "SZSE.000636",
    "SHSE.600123", "SHSE.600060", "SHSE.688388", "SHSE.603595", "SHSE.600764", "SHSE.601921", "SHSE.600066",
    "SZSE.002558", "SZSE.002368", "SZSE.300339", "SHSE.600022", "SZSE.300001", "SHSE.603906", "SZSE.002429",
    "SZSE.002698", "SZSE.000970", "SZSE.300383", "SZSE.000657", "SZSE.300679", "SHSE.688192", "SHSE.688639",
    "SZSE.000927", "SHSE.600901", "SHSE.600339", "SHSE.605507", "SZSE.002958", "SZSE.000935", "SHSE.603098",
    "SZSE.002291", "SZSE.300088", "SZSE.300418", "SZSE.002092", "SHSE.601608", "SZSE.002456", "SZSE.300827",
    "SHSE.600179", "SHSE.601222", "SZSE.000860", "SHSE.600116", "SHSE.688559", "SZSE.300294", "SHSE.600248",
    "SZSE.301090", "SHSE.600388", "SHSE.688289", "SZSE.000930", "SHSE.603866", "SHSE.688270", "SHSE.603025",
    "SHSE.603027", "SZSE.000049", "SZSE.300821", "SHSE.601000", "SHSE.600100", "SHSE.688383", "SZSE.000686",
    "SZSE.000967", "SHSE.601882", "SZSE.002837", "SHSE.603730", "SZSE.000429", "SZSE.002085", "SHSE.601326",
    "SHSE.600675", "SHSE.600323", "SZSE.000921", "SHSE.603128", "SZSE.301050", "SHSE.600259", "SHSE.601702",
    "SHSE.600850", "SHSE.600928", "SHSE.600967", "SZSE.002544", "SZSE.002670", "SHSE.688055", "SZSE.002151",
    "SZSE.000060", "SHSE.600395", "SZSE.000598", "SZSE.002258", "SZSE.000902", "SHSE.600882", "SZSE.002675",
    "SZSE.002461", "SZSE.300296", "SZSE.002139", "SHSE.600707", "SZSE.002158", "SHSE.603588", "SHSE.600167",
    "SZSE.002036", "SHSE.600959", "SZSE.301015", "SHSE.600055", "SZSE.300567", "SZSE.001914", "SHSE.603298",
    "SZSE.000997", "SZSE.000627", "SHSE.603379", "SZSE.300115", "SHSE.600737", "SZSE.300596", "SZSE.002373",
    "SZSE.300741", "SZSE.300677", "SHSE.600428", "SHSE.600773", "SHSE.603489", "SZSE.000488", "SHSE.600478",
    "SHSE.688408", "SZSE.300035", "SHSE.601677", "SZSE.000778", "SHSE.688298", "SHSE.605090", "SZSE.000402",
    "SZSE.002010", "SZSE.300024", "SHSE.600151", "SHSE.688608", "SZSE.300841", "SHSE.600740", "SZSE.002610",
    "SZSE.300672", "SHSE.600610", "SHSE.688366", "SHSE.688133", "SHSE.600755", "SHSE.688110", "SHSE.600718",
    "SHSE.600007", "SZSE.300623", "SHSE.688798", "SZSE.000415", "SHSE.601333", "SZSE.002423", "SHSE.600126",
    "SZSE.002585", "SZSE.000028", "SZSE.002183", "SHSE.601005", "SHSE.605296", "SHSE.601187", "SHSE.600195",
    "SZSE.000031", "SZSE.002402", "SHSE.688239", "SZSE.002737", "SZSE.002925", "SZSE.300482", "SZSE.002978",
    "SZSE.002019", "SZSE.300525", "SZSE.300382", "SHSE.601969", "SHSE.601778", "SZSE.002212", "SZSE.002121",
    "SZSE.000951", "SZSE.000403", "SHSE.600507", "SZSE.000567", "SHSE.603100", "SZSE.002705", "SHSE.603005",
    "SZSE.002091", "SHSE.600328", "SZSE.300416", "SZSE.300017", "SHSE.603171", "SHSE.600376", "SHSE.600199",
    "SZSE.300502", "SHSE.603308", "SHSE.603039", "SHSE.603033", "SHSE.600597", "SHSE.600648", "SZSE.300451",
    "SZSE.000089", "SHSE.600171", "SHSE.600623", "SHSE.688739", "SZSE.002221", "SHSE.603997", "SZSE.300457",
    "SHSE.603915", "SZSE.002643", "SZSE.301047", "SHSE.605589", "SZSE.002249", "SHSE.600267", "SHSE.601718",
    "SZSE.002534", "SHSE.600771", "SHSE.601137", "SZSE.000821", "SZSE.002226", "SZSE.002411", "SHSE.600435",
    "SZSE.300456", "SZSE.002572", "SZSE.002517", "SHSE.600063", "SHSE.688789", "SZSE.000156", "SHSE.688001",
    "SHSE.603612", "SZSE.000422", "SHSE.603063", "SHSE.603979", "SZSE.002706", "SZSE.002287", "SZSE.002851",
    "SHSE.603690", "SZSE.000582", "SHSE.600876", "SZSE.002832", "SZSE.300973", "SHSE.600869", "SHSE.600120",
    "SHSE.600389", "SZSE.300618", "SZSE.002006", "SZSE.300443", "SHSE.603225", "SZSE.002216", "SHSE.601019",
    "SZSE.002416", "SZSE.002745", "SZSE.002396", "SZSE.300674", "SHSE.603301", "SZSE.300343", "SHSE.605376",
    "SZSE.002511", "SHSE.600330", "SZSE.300458", "SHSE.603132", "SHSE.688800", "SZSE.000550", "SZSE.002701",
    "SZSE.002182", "SHSE.600363", "SZSE.000035", "SZSE.002960", "SZSE.300687", "SZSE.002867", "SZSE.000966",
    "SZSE.300379", "SHSE.601519", "SZSE.002549", "SZSE.002563", "SHSE.605369", "SHSE.603306", "SHSE.601038",
    "SHSE.688262", "SHSE.600839", "SHSE.600776", "SZSE.000756", "SHSE.603985", "SHSE.603638", "SZSE.300463",
    "SZSE.300613", "SHSE.600422", "SHSE.601126", "SZSE.002281", "SHSE.600155", "SHSE.600996", "SHSE.688123",
    "SHSE.603515", "SZSE.002195", "SHSE.600273", "SZSE.002101", "SHSE.688033", "SHSE.688097", "SHSE.603567",
    "SZSE.000410", "SHSE.600409", "SHSE.688100", "SHSE.605222", "SHSE.600595", "SZSE.300773", "SZSE.300058",
    "SZSE.000016", "SHSE.600657", "SHSE.600917", "SZSE.000690", "SZSE.002081", "SHSE.600835", "SHSE.601512",
    "SZSE.300638", "SHSE.688112", "SZSE.002219", "SHSE.603728", "SHSE.688696", "SHSE.688269", "SZSE.000761",
    "SHSE.603032", "SZSE.300476", "SZSE.002048", "SHSE.603043", "SHSE.600373", "SZSE.002131", "SZSE.002866",
    "SZSE.300630", "SZSE.301069", "SZSE.002254", "SHSE.601811", "SHSE.600370", "SZSE.002539", "SZSE.000528",
    "SZSE.002100", "SZSE.000563", "SZSE.000712", "SHSE.600586", "SHSE.603983", "SHSE.600782", "SHSE.688190",
    "SHSE.600639", "SHSE.688677", "SZSE.000062", "SZSE.000555", "SHSE.600621", "SHSE.600587", "SHSE.605333",
    "SHSE.601107", "SZSE.002020", "SZSE.300737", "SZSE.000420", "SZSE.300587", "SZSE.300182", "SHSE.600452",
    "SHSE.600667", "SHSE.600717", "SHSE.600955", "SHSE.688575", "SHSE.688131", "SHSE.603719", "SZSE.002847",
    "SHSE.600662", "SHSE.600682", "SHSE.688526", "SHSE.600446", "SHSE.600557", "SZSE.002011", "SHSE.600929",
    "SZSE.000990", "SHSE.601068", "SHSE.600206", "SZSE.002581", "SHSE.600012", "SZSE.002242", "SHSE.600037",
    "SZSE.002157", "SZSE.300188", "SZSE.002793", "SZSE.000915", "SZSE.002124", "SHSE.600335", "SHSE.603363",
    "SZSE.300394", "SHSE.600216", "SHSE.688680", "SZSE.002993", "SZSE.000682", "SHSE.600618", "SZSE.002127",
    "SZSE.000498", "SHSE.600006", "SHSE.688315", "SZSE.300212", "SHSE.688091", "SHSE.600888", "SHSE.688106",
    "SHSE.600225", "SZSE.300768", "SZSE.301078", "SHSE.603297", "SHSE.600400", "SHSE.600556", "SHSE.601827",
    "SZSE.002099", "SHSE.601918", "SHSE.600532", "SZSE.002349", "SZSE.300693", "SZSE.300811", "SHSE.600572",
    "SZSE.002453", "SZSE.002928", "SZSE.000059", "SHSE.600064", "SZSE.300080", "SHSE.601258", "SZSE.002987",
    "SHSE.600403", "SHSE.600567", "SZSE.300327", "SHSE.600997", "SHSE.603223", "SZSE.300459", "SHSE.603398",
    "SHSE.603766", "SZSE.002237", "SHSE.603396", "SZSE.002191", "SZSE.002204", "SHSE.688596", "SZSE.002907",
    "SHSE.600313", "SZSE.002911", "SZSE.002063", "SHSE.688268", "SZSE.301031", "SHSE.600185", "SZSE.000426",
    "SZSE.000543", "SZSE.300990", "SZSE.300261", "SHSE.603000", "SHSE.603871", "SZSE.300406", "SZSE.300799",
    "SHSE.603938", "SHSE.603229", "SHSE.600821", "SZSE.002895", "SHSE.688518", "SHSE.600818", "SHSE.601069",
    "SZSE.300767", "SHSE.605008", "SZSE.002390", "SHSE.688311", "SZSE.300332", "SZSE.002320", "SHSE.603693",
    "SZSE.000413", "SHSE.603609", "SZSE.301018", "SZSE.000767", "SZSE.002004", "SZSE.002626", "SHSE.600508",
    "SZSE.300168", "SZSE.002110", "SHSE.601678", "SHSE.605020", "SZSE.002079", "SZSE.000088", "SZSE.000546",
    "SZSE.003039", "SZSE.300887", "SZSE.300598", "SZSE.300075", "SZSE.002002", "SHSE.600812", "SZSE.002332",
    "SHSE.688088", "SHSE.688586", "SHSE.603919", "SZSE.002077", "SZSE.301217", "SHSE.688173", "SZSE.300224",
    "SHSE.600787", "SZSE.002726", "SZSE.002088", "SHSE.600761", "SHSE.688007", "SZSE.300166", "SHSE.688266",
    "SHSE.600841", "SHSE.600305", "SZSE.002446", "SZSE.300087", "SZSE.000158", "SHSE.601311", "SHSE.600728",
    "SZSE.002932", "SZSE.002545", "SHSE.600734", "SHSE.600163", "SHSE.605116", "SHSE.600993", "SHSE.688356",
    "SZSE.300185", "SZSE.002434", "SZSE.002967", "SZSE.002458", "SHSE.601200", "SZSE.002003", "SZSE.002171",
    "SZSE.000540", "SZSE.000948", "SHSE.600366", "SZSE.000672", "SZSE.002126", "SHSE.605099", "SZSE.300772",
    "SHSE.601208", "SHSE.600312", "SHSE.601609", "SZSE.300869", "SHSE.603477", "SHSE.603989", "SHSE.601163",
    "SHSE.603566", "SZSE.002839", "SZSE.002930", "SHSE.600963", "SZSE.002053", "SZSE.300358", "SZSE.300236",
    "SHSE.688578", "SZSE.000090", "SZSE.002061", "SHSE.600307", "SZSE.300348", "SZSE.000685", "SZSE.002583",
    "SHSE.688236", "SZSE.300151", "SHSE.603583", "SHSE.688212", "SZSE.002819", "SHSE.600750", "SZSE.300856",
    "SZSE.300199", "SZSE.002051", "SZSE.301089", "SHSE.688505", "SHSE.603337", "SHSE.688321", "SZSE.002965",
    "SHSE.600746", "SZSE.002815", "SZSE.000656", "SHSE.688305", "SHSE.603071", "SHSE.600971", "SHSE.600252",
    "SZSE.300655", "SZSE.300072", "SZSE.002424", "SZSE.002243", "SZSE.300119", "SHSE.600874", "SHSE.600575",
    "SZSE.002276", "SHSE.601619", "SZSE.002190", "SZSE.300685", "SHSE.601886", "SZSE.000727", "SHSE.600602",
    "SZSE.000503", "SHSE.600864", "SZSE.000029", "SZSE.002261", "SZSE.300415", "SHSE.600201", "SZSE.300036",
    "SHSE.600477", "SHSE.601860", "SZSE.300233", "SHSE.600603", "SHSE.600420", "SHSE.601528", "SZSE.003040",
    "SHSE.600211", "SZSE.002840", "SHSE.603212", "SZSE.300573", "SHSE.688167", "SZSE.000600", "SZSE.300323",
    "SHSE.601101", "SZSE.002859", "SZSE.002125", "SHSE.601015", "SHSE.601801", "SZSE.000718", "SZSE.301060",
    "SHSE.600811", "SZSE.000828", "SZSE.300586", "SZSE.000595", "SZSE.300755", "SZSE.300217", "SZSE.301080",
    "SZSE.300109", "SZSE.000829", "SZSE.002665", "SZSE.000839", "SZSE.000078", "SHSE.605286", "SHSE.600775",
    "SZSE.002123", "SHSE.601330", "SZSE.300398", "SHSE.600770", "SZSE.002537", "SHSE.600604", "SZSE.300369",
    "SHSE.600649", "SHSE.688658", "SHSE.688027", "SZSE.000913", "SZSE.003021", "SZSE.300639", "SHSE.600908",
    "SHSE.600475", "SZSE.002946", "SHSE.600976", "SZSE.300093", "SZSE.002959", "SHSE.601890", "SZSE.000950",
    "SZSE.002818", "SHSE.600197", "SHSE.603920", "SZSE.300894", "SZSE.300602", "SHSE.600459", "SZSE.300077",
    "SZSE.000650", "SZSE.300671", "SZSE.300705", "SZSE.002635", "SZSE.002201", "SZSE.000758", "SHSE.600645",
    "SHSE.600072", "SHSE.600783", "SZSE.300470", "SZSE.002805", "SHSE.600075", "SHSE.605365", "SHSE.603636",
    "SZSE.000048", "SHSE.600966", "SZSE.002146", "SHSE.688166", "SZSE.000061", "SZSE.000837", "SHSE.601003",
    "SZSE.002897", "SHSE.603393", "SZSE.002068", "SHSE.600058", "SHSE.603197", "SZSE.300138", "SHSE.688630",
    "SZSE.300065", "SHSE.603300", "SHSE.603639", "SZSE.002075", "SZSE.000811", "SZSE.002514", "SHSE.603556",
    "SHSE.600340", "SZSE.300002", "SHSE.603881", "SZSE.002038", "SHSE.603008", "SHSE.688711", "SZSE.300765",
    "SZSE.301096", "SHSE.600903", "SZSE.300634", "SHSE.688733", "SZSE.002929", "SZSE.002275", "SHSE.600577",
    "SHSE.603358", "SZSE.300229", "SHSE.688660", "SZSE.002567", "SHSE.600635", "SHSE.603123", "SHSE.688389",
    "SHSE.600643", "SHSE.600851", "SZSE.002440", "SZSE.002645", "SHSE.603035", "SZSE.002267", "SZSE.002302",
    "SHSE.688318", "SZSE.002426", "SHSE.600078", "SHSE.600550", "SHSE.600496", "SZSE.000534", "SZSE.002612",
    "SZSE.300481", "SHSE.688075", "SHSE.688336", "SZSE.000517", "SZSE.003005", "SZSE.301101", "SZSE.300409",
    "SZSE.002382", "SZSE.002163", "SHSE.600491", "SZSE.002913", "SHSE.688201", "SHSE.688177", "SZSE.002217",
    "SZSE.000030", "SHSE.600158", "SZSE.000969", "SHSE.688183", "SHSE.688339", "SHSE.600823", "SZSE.002810",
    "SZSE.301058", "SZSE.301168", "SZSE.002149", "SHSE.603299", "SHSE.600285", "SZSE.002314", "SZSE.002387",
    "SZSE.000631", "SZSE.002239", "SZSE.000737", "SZSE.000801", "SHSE.603303", "SZSE.002214", "SZSE.003012",
    "SZSE.300696", "SZSE.000968", "SHSE.688533", "SHSE.600633", "SHSE.600017", "SHSE.603995", "SHSE.600729",
    "SZSE.002807", "SZSE.002130", "SZSE.000848", "SHSE.603169", "SHSE.600198", "SHSE.603323", "SZSE.300315",
    "SZSE.002233", "SZSE.003038", "SZSE.300702", "SZSE.300401", "SZSE.000899", "SHSE.688553", "SZSE.000670",
    "SZSE.002093", "SZSE.300712", "SHSE.603219", "SHSE.600651", "SZSE.300133", "SHSE.603053", "SHSE.605339",
    "SHSE.688621", "SHSE.688157", "SZSE.300723", "SZSE.000019", "SZSE.300953", "SHSE.600169", "SHSE.600059",
    "SHSE.600502", "SHSE.688225", "SHSE.603383", "SZSE.000552", "SZSE.002293", "SHSE.601339", "SZSE.000957",
    "SHSE.603888", "SHSE.601606", "SHSE.688196", "SZSE.002060", "SZSE.002950", "SZSE.000065", "SHSE.601515",
    "SHSE.603327", "SHSE.600696", "SHSE.601686", "SZSE.301073", "SHSE.600710", "SHSE.600138", "SZSE.002034",
    "SZSE.000572", "SZSE.002838", "SHSE.600973", "SHSE.600094", "SZSE.000961", "SHSE.603181", "SHSE.688233",
    "SHSE.601279", "SZSE.300170", "SHSE.605108", "SZSE.002746", "SZSE.002556", "SZSE.002941", "SHSE.603060",
    "SZSE.002108", "SZSE.002782", "SZSE.002678", "SHSE.603113", "SZSE.001896", "SHSE.601949", "SZSE.000982",
    "SZSE.300762", "SHSE.600523", "SZSE.002135", "SHSE.601968", "SHSE.600210", "SHSE.603187", "SHSE.688128",
    "SZSE.002102", "SHSE.603855", "SZSE.002755", "SHSE.600054", "SHSE.600084", "SHSE.603399", "SHSE.603103",
    "SHSE.600172", "SHSE.600720", "SHSE.688560", "SZSE.002937", "SZSE.300833", "SHSE.605399", "SHSE.600266",
    "SHSE.600510", "SZSE.300116", "SHSE.603877", "SZSE.300518", "SZSE.300129", "SHSE.600620", "SZSE.002501",
    "SZSE.300579", "SZSE.002550", "SHSE.600033", "SHSE.603619", "SZSE.002573", "SZSE.000989", "SHSE.688377",
    "SHSE.603138", "SHSE.600987", "SZSE.000597", "SHSE.603055", "SHSE.600353", "SHSE.688513", "SHSE.688636",
    "SZSE.300653", "SHSE.600552", "SZSE.000795", "SZSE.300735", "SHSE.605183", "SZSE.301180", "SZSE.001696",
    "SZSE.300770", "SHSE.600780", "SZSE.300208", "SHSE.600269", "SHSE.688308", "SHSE.600226", "SZSE.300663",
    "SHSE.600881", "SHSE.600810", "SHSE.600480", "SZSE.000557", "SZSE.300718", "SZSE.002400", "SZSE.000719",
    "SHSE.600744", "SZSE.000501", "SZSE.300284", "SHSE.603666", "SZSE.000735", "SHSE.600461", "SZSE.002270",
    "SZSE.000813", "SZSE.300008", "SZSE.300569", "SZSE.300475", "SZSE.002489", "SHSE.600691", "SHSE.601388",
    "SZSE.002351", "SZSE.002733", "SHSE.603067", "SHSE.688148", "SZSE.300206", "SHSE.603668", "SHSE.600230",
    "SZSE.002955", "SHSE.600860", "SZSE.000912", "SZSE.002166", "SZSE.002174", "SZSE.002169", "SZSE.000681",
    "SZSE.002640", "SHSE.603013", "SZSE.000736", "SZSE.300982", "SZSE.002777", "SZSE.300575", "SHSE.600640",
    "SZSE.300079", "SHSE.688003", "SHSE.605168", "SZSE.002218", "SHSE.603118", "SHSE.605599", "SZSE.000025",
    "SZSE.300337", "SHSE.688186", "SHSE.688317", "SZSE.002323", "SHSE.601020", "SZSE.000676", "SZSE.002759",
    "SHSE.603283", "SZSE.002516", "SZSE.301087", "SHSE.688127", "SHSE.600458", "SZSE.002768", "SZSE.300113",
    "SZSE.000755", "SZSE.002356", "SZSE.002992", "SHSE.688085", "SHSE.600664", "SZSE.000881", "SZSE.300130",
    "SHSE.603105", "SZSE.301206", "SZSE.002741", "SZSE.300319", "SZSE.000058", "SZSE.300352", "SZSE.301117",
    "SZSE.000671", "SHSE.688018", "SZSE.002957", "SHSE.603010", "SZSE.002881", "SHSE.600106", "SZSE.002681",
    "SHSE.600537", "SZSE.002386", "SZSE.002543", "SZSE.002057", "SZSE.000541", "SHSE.603901", "SHSE.603328",
    "SZSE.002047", "SZSE.300085", "SZSE.002046", "SZSE.002651", "SHSE.603277", "SHSE.605366", "SZSE.000791",
    "SZSE.000901", "SHSE.603896", "SHSE.600751", "SZSE.300783", "SHSE.600125", "SZSE.300806", "SZSE.002274",
    "SZSE.000525", "SZSE.002023", "SZSE.002491", "SZSE.300792", "SHSE.688151", "SZSE.300125", "SZSE.002413",
    "SZSE.002334", "SHSE.600713", "SZSE.300181", "SZSE.000822", "SHSE.688663", "SZSE.003043", "SZSE.300607",
    "SZSE.300360", "SZSE.000928", "SZSE.300497", "SHSE.603676", "SHSE.603387", "SHSE.600360", "SZSE.002481",
    "SHSE.605077", "SHSE.600611", "SZSE.002097", "SHSE.603698", "SZSE.002338", "SZSE.300527", "SZSE.300942",
    "SZSE.002649", "SZSE.002703", "SZSE.003032", "SZSE.002470", "SZSE.000917", "SZSE.000603", "SHSE.600223",
    "SHSE.601226", "SZSE.300180", "SZSE.300232", "SZSE.002197", "SZSE.000726", "SHSE.603069", "SHSE.601199",
    "SZSE.002538", "SHSE.600490", "SHSE.688697", "SHSE.601900", "SZSE.300893", "SHSE.688176", "SHSE.603699",
    "SHSE.601011", "SZSE.002588", "SZSE.002194", "SZSE.002428", "SHSE.600939", "SZSE.300267", "SZSE.300041",
    "SZSE.300256", "SZSE.301116", "SZSE.300005", "SZSE.002716", "SZSE.000717", "SZSE.300396", "SHSE.688330",
    "SHSE.603368", "SHSE.603680", "SHSE.600284", "SHSE.603801", "SZSE.300681", "SHSE.688222", "SZSE.002677",
    "SHSE.600525", "SHSE.600797", "SHSE.603800", "SHSE.605060", "SHSE.605009", "SHSE.603587", "SZSE.002552",
    "SZSE.002724", "SZSE.002222", "SZSE.003009", "SZSE.002833", "SZSE.002639", "SZSE.300143", "SHSE.603203",
    "SHSE.603110", "SZSE.300320", "SZSE.300900", "SZSE.001201", "SZSE.300738", "SZSE.002540", "SZSE.300134",
    "SHSE.605368", "SZSE.002292", "SZSE.300055", "SZSE.000815", "SZSE.002547", "SHSE.603718", "SHSE.688368",
    "SZSE.002758", "SZSE.002017", "SZSE.301017", "SZSE.300427", "SHSE.600251", "SZSE.002765", "SZSE.300662",
    "SZSE.002829", "SZSE.300377", "SHSE.603665", "SHSE.688267", "SHSE.603108", "SZSE.002707", "SHSE.600429",
    "SZSE.300366", "SHSE.600073", "SZSE.002022", "SZSE.002589", "SZSE.002801", "SHSE.688766", "SZSE.002697",
    "SZSE.002488", "SZSE.000851", "SZSE.002935", "SZSE.000789", "SHSE.600742", "SHSE.603533", "SZSE.000665",
    "SZSE.300263", "SZSE.300660", "SZSE.000008", "SZSE.300114", "SZSE.002073", "SHSE.600433", "SHSE.605198",
    "SZSE.300183", "SZSE.002280", "SZSE.300123", "SZSE.002668", "SZSE.001313", "SZSE.000819", "SHSE.600509",
    "SHSE.600053", "SZSE.300179", "SZSE.003029", "SZSE.002421", "SZSE.002530", "SHSE.688162", "SZSE.000680",
    "SZSE.002876", "SZSE.000720", "SHSE.600990", "SHSE.605005", "SHSE.600278", "SHSE.688625", "SZSE.000976",
    "SZSE.003013", "SHSE.605377", "SHSE.603916", "SZSE.002646", "SHSE.688319", "SZSE.000923", "SZSE.002206",
    "SHSE.601588", "SZSE.300197", "SHSE.600986", "SZSE.300057", "SZSE.000885", "SHSE.601579", "SZSE.300258",
    "SHSE.600619", "SHSE.603466", "SHSE.600391", "SHSE.600757", "SZSE.300996", "SZSE.003037", "SZSE.002990",
    "SHSE.603315", "SHSE.603078", "SZSE.002378", "SZSE.300581", "SZSE.300007", "SHSE.605338", "SHSE.688158",
    "SZSE.300196", "SHSE.605138", "SZSE.300278", "SZSE.002210", "SHSE.600217", "SZSE.300468", "SHSE.688768",
    "SHSE.688399", "SZSE.002132", "SZSE.000612", "SHSE.603987", "SHSE.600184", "SZSE.002961", "SHSE.600121",
    "SZSE.002082", "SZSE.002455", "SHSE.605199", "SHSE.603309", "SZSE.002979", "SHSE.603959", "SZSE.300619",
    "SHSE.688508", "SHSE.600020", "SHSE.600410", "SHSE.605050", "SZSE.300039", "SHSE.605266", "SHSE.688103",
    "SZSE.002307", "SHSE.688283", "SHSE.603520", "SZSE.300455", "SHSE.603416", "SHSE.603936", "SZSE.002882",
    "SHSE.688138", "SHSE.600981", "SZSE.002845", "SZSE.002880", "SZSE.002467", "SHSE.688277", "SZSE.002031",
    "SZSE.000900", "SZSE.300809", "SZSE.002283", "SHSE.601858", "SHSE.688369", "SZSE.000046", "SZSE.002437",
    "SHSE.603970", "SZSE.002419", "SZSE.300271", "SHSE.688062", "SZSE.300620", "SHSE.600576", "SHSE.600231",
    "SHSE.600343", "SHSE.603256", "SZSE.300951", "SHSE.600108", "SHSE.603708", "SHSE.603421", "SHSE.688668",
    "SHSE.603227", "SZSE.300019", "SHSE.603511", "SHSE.600308", "SZSE.300872", "SHSE.600790", "SZSE.002354",
    "SZSE.002346", "SHSE.603367", "SHSE.688606", "SZSE.300174", "SZSE.300131", "SZSE.002636", "SZSE.300091",
    "SZSE.002891", "SHSE.605007", "SZSE.000544", "SZSE.300049", "SZSE.300825", "SZSE.002055", "SZSE.002059",
    "SZSE.002528", "SZSE.300802", "SHSE.603324", "SHSE.688767", "SZSE.002623", "SHSE.600190", "SZSE.002375",
    "SZSE.002104", "SHSE.603429", "SZSE.300098", "SZSE.300027", "SZSE.300191", "SHSE.600681", "SZSE.000652",
    "SZSE.002329", "SZSE.002043", "SZSE.300969", "SZSE.300548", "SZSE.002045", "SZSE.002824", "SHSE.600228",
    "SZSE.002438", "SZSE.300566", "SHSE.601929", "SZSE.002729", "SZSE.002996", "SHSE.600984", "SZSE.300485",
    "SZSE.300617", "SHSE.600617", "SHSE.600861", "SZSE.300326", "SHSE.688300", "SZSE.002478", "SHSE.688626",
    "SHSE.603530", "SZSE.002915", "SZSE.000906", "SHSE.601700", "SHSE.688665", "SZSE.000505", "SZSE.300303",
    "SZSE.300048", "SHSE.600789", "SHSE.605011", "SHSE.603155", "SHSE.603738", "SZSE.300873", "SHSE.600180",
    "SZSE.300981", "SHSE.600114", "SZSE.300447", "SZSE.002664", "SZSE.002435", "SHSE.688601", "SZSE.000524",
    "SHSE.605388", "SZSE.002234", "SZSE.300477", "SHSE.603213", "SHSE.605305", "SZSE.300480", "SZSE.300860",
    "SZSE.300659", "SZSE.000036", "SHSE.600569", "SHSE.603931", "SHSE.688022", "SZSE.002667", "SZSE.000722",
    "SZSE.000861", "SZSE.002644", "SHSE.603093", "SZSE.300565", "SHSE.605555", "SZSE.300365", "SHSE.600590",
    "SZSE.002009", "SHSE.600288", "SZSE.002039", "SZSE.000099", "SZSE.300031", "SHSE.600162", "SHSE.688699",
    "SZSE.002284", "SZSE.300341", "SZSE.000922", "SZSE.000566", "SHSE.603960", "SZSE.000011", "SZSE.301099",
    "SHSE.600894", "SHSE.600545", "SZSE.002106", "SZSE.300324", "SZSE.300082", "SZSE.002327", "SZSE.000040",
    "SHSE.688068", "SZSE.300523", "SHSE.600449", "SHSE.688345", "SZSE.300636", "SZSE.002062", "SHSE.603112",
    "SHSE.600609", "SZSE.002562", "SZSE.002310", "SHSE.603208", "SZSE.000536", "SHSE.600152", "SZSE.300364",
    "SZSE.002483", "SHSE.600975", "SZSE.000852", "SZSE.000666", "SZSE.002991", "SZSE.000560", "SZSE.300158",
    "SZSE.300722", "SZSE.002641", "SZSE.002605", "SZSE.300986", "SHSE.600748", "SZSE.300255", "SHSE.600804",
    "SZSE.300708", "SHSE.600601", "SZSE.300709", "SHSE.600581", "SZSE.300248", "SZSE.300287", "SZSE.300354",
    "SZSE.300576", "SZSE.000905", "SHSE.688682", "SZSE.300102", "SZSE.300532", "SZSE.002519", "SHSE.605118",
    "SZSE.002884", "SHSE.600828", "SHSE.603633", "SHSE.600846", "SZSE.002111", "SHSE.603555", "SZSE.300397",
    "SZSE.000070", "SZSE.300222", "SZSE.300978", "SZSE.002657", "SZSE.300286", "SHSE.603366", "SZSE.301201",
    "SZSE.300053", "SZSE.300680", "SZSE.300066", "SHSE.600331", "SHSE.688468", "SHSE.600992", "SHSE.688359",
    "SHSE.688093", "SHSE.605018", "SHSE.603601", "SHSE.688280", "SZSE.002611", "SZSE.002367", "SZSE.300205",
    "SHSE.600531", "SZSE.002246", "SZSE.002303", "SHSE.688259", "SHSE.603538", "SZSE.002300", "SZSE.002279",
    "SZSE.002109", "SZSE.002232", "SZSE.000055", "SHSE.603992", "SZSE.002263", "SHSE.603018", "SZSE.000816",
    "SHSE.600207", "SZSE.301123", "SZSE.002922", "SZSE.301149", "SHSE.688221", "SZSE.300842", "SZSE.001208",
    "SZSE.300590", "SZSE.300226", "SZSE.300384", "SZSE.300435", "SHSE.600071", "SZSE.000903", "SZSE.002301",
    "SZSE.000766", "SHSE.688182", "SZSE.300790", "SZSE.002662", "SZSE.301179", "SZSE.002288", "SHSE.601008",
    "SHSE.603667", "SHSE.603122", "SHSE.600650", "SZSE.002454", "SZSE.002431", "SZSE.002090", "SHSE.600381",
    "SZSE.002445", "SHSE.688230", "SZSE.002542", "SZSE.300916", "SHSE.688179", "SZSE.002298", "SZSE.300204",
    "SZSE.000697", "SHSE.603777", "SZSE.002918", "SZSE.300219", "SZSE.002042", "SZSE.002943", "SZSE.002215",
    "SHSE.688059", "SZSE.000531", "SHSE.600983", "SZSE.002642", "SHSE.688661", "SZSE.300815", "SZSE.002520",
    "SHSE.688357", "SHSE.603439", "SHSE.688595", "SHSE.600103", "SZSE.000838", "SHSE.600105", "SZSE.002383",
    "SZSE.002908", "SZSE.300318", "SHSE.688087", "SHSE.600501", "SZSE.002885", "SZSE.000823", "SHSE.688095",
    "SZSE.002285", "SZSE.002785", "SZSE.002154", "SZSE.300184", "SZSE.000713", "SHSE.605300", "SZSE.002614",
    "SZSE.300657", "SZSE.002658", "SZSE.002750", "SZSE.002570", "SHSE.600936", "SHSE.603217", "SHSE.603611",
    "SHSE.603867", "SHSE.603977", "SZSE.300353", "SHSE.688313", "SHSE.605006", "SZSE.300061", "SHSE.603136",
    "SZSE.300648", "SZSE.300355", "SHSE.600565", "SZSE.002376", "SZSE.300177", "SZSE.002449", "SZSE.001267",
    "SHSE.688358", "SZSE.300846", "SZSE.300506", "SZSE.000584", "SZSE.000576", "SZSE.300801", "SZSE.002609",
    "SZSE.002344", "SHSE.605337", "SHSE.600268", "SZSE.002912"
]

# run_codes = []

print(len(run_codes))

# 创建表
db_ex.create_tables(run_codes)

# 当前时间
now_datetime = datetime.datetime.now()

# 默认第一次同步的起始时间，后续则进行增量更新
sync_frequencys = {
    'd': {'start': '2005-01-01 00:00:00'},
    '30m': {'start': '2016-01-01 00:00:00'},
    '5m': {'start': '2016-01-01 00:00:00'},
    # '1m': {'start': '2018-01-01 00:00:00'},
}
# 本地周期与掘金周期对应关系
fre_maps = {
    '1m': '60s', '5m': '300s', '30m': '1800s', 'd': '1d'
}

# K线数据采用后复权，可增量更新
is_update = False
for code in tqdm(run_codes):

    # 中途终端后，可以设置下次起始的代码
    # if not is_update and code == 'SHSE.600433':
    #     is_update = True
    # if not is_update:
    #     continue

    for f, dt in sync_frequencys.items():
        try:
            while True:
                time.sleep(1)
                last_dt = db_ex.query_last_datetime(code, f)
                if last_dt is None:
                    last_dt = dt['start']
                klines = history(
                    code, fre_maps[f], start_time=last_dt, end_time=now_datetime, adjust=ADJUST_POST, df=True,
                    fill_missing='Last'
                )
                klines.loc[:, 'code'] = klines['symbol']
                klines.loc[:, 'date'] = pd.to_datetime(klines['eob'])
                klines = klines[['code', 'date', 'open', 'close', 'high', 'low', 'volume']]
                print('Run code %s frequency %s klines len %s' % (code, f, len(klines)))
                db_ex.insert_klines(code, f, klines)
                if len(klines) < 500:
                    break
        except Exception as e:
            print('执行 %s 同步K线异常' % code)
            print(traceback.format_exc())
            time.sleep(10)
